package com.odais;

import android.app.TabActivity;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.widget.TabHost;

import com.odais.AE_Planner.RoomPlanner;
import com.odais.DataManagement.DataManager;
import com.odais.UserManagement.UserManager;
import com.odais.mvc.seller.sellerListViewMain;
import com.odais.notif.C2DM_ToolBox;

/**
 *
 * @author Lionel DECELLE
 * @since 8 juin 2012 - 10:52:47
 *
 */


public class OD_GLES2Activity extends TabActivity {

	public static String CustID;
	public UserManager userManager;
	public DataManager dataManager;
	

	/** Called when the activity is first created. */
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
       // setContentView(R.layout.main);
        setContentView(R.layout.maintab03);
//        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
//        StrictMode.setThreadPolicy(policy);


        dataManager = new DataManager(this);
        userManager = new UserManager(this, dataManager);
        userManager.Hello();
        
        
        
        //userManager.ShowLogginPopup();
        //Check if this device has a CustID
        //If not, create it and register it in the server database
        //CustID = ODAIS_DB_Toolbox.ODAIS_DB_Client_ID_Check(this);

        new C2DMTask().execute();

//        //tabhost declaration
//        TabHost tabHost = getTabHost();
//        TabHost.TabSpec spec;
//        Intent intent;
//
//
//        intent = new Intent().setClass(this, mainTab02.class);
//        spec = tabHost.newTabSpec("Tab02").setIndicator("Customer Tab").setContent(intent);
//        tabHost.addTab(spec);
//
//        intent = new Intent().setClass(this, sellerMainItf.class);
//        spec = tabHost.newTabSpec("Tab03").setIndicator("Seller Tab").setContent(intent);
//        tabHost.addTab(spec);
//
//        tabHost.getTabWidget().getChildAt(0).getLayoutParams().height = 50;
//        tabHost.getTabWidget().getChildAt(1).getLayoutParams().height = 50;
//
//        tabHost.setCurrentTab(1);

        
        //tabhost declaration
        TabHost sellerTabHost = getTabHost();
        TabHost.TabSpec spec;
        Intent intent;
        
        //List View history
        
        intent = new Intent().setClass(this, sellerListViewMain.class);
        spec = sellerTabHost.newTabSpec("SellerListView").setIndicator("Reservations").setContent(intent);
        sellerTabHost.addTab(spec);

        // Room planner
        intent = new Intent().setClass(this, RoomPlanner.class);
        spec = sellerTabHost.newTabSpec("RoomPlanner").setIndicator("Room Planner").setContent(intent);
        sellerTabHost.addTab(spec);

        sellerTabHost.getTabWidget().getChildAt(0).getLayoutParams().height = 50;
        sellerTabHost.getTabWidget().getChildAt(1).getLayoutParams().height = 50;

        sellerTabHost.setCurrentTab(1);
    }


	  class C2DMTask extends AsyncTask<Void, String, Void> {
		    @Override
		protected void onPreExecute()
		{}

			@Override
		    protected Void doInBackground(Void... unused) {


		        //C2DM
		      C2DM_ToolBox C2DM_Tool = new C2DM_ToolBox();
		      C2DM_Tool.C2DM_Register(getApplicationContext());
		      return(null);
		    }

		    @Override
		    protected void onProgressUpdate(String... item) {
		    	//mProgressBar.set
		    }

		    @Override
		    protected void onPostExecute(Void unused) {

		    }
		  }

}